package grails.company



import grails.test.mixin.*
import org.junit.*

/**
 * See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions
 */
@TestFor(Department)
class DepartmentTests {

    Organization o

    @Before
    void setUp() {
        mockDomain(Organization, [[title: 'ACME']])
        o = Organization.findByTitle('ACME')
    }

    void testTitleConstraint() {
        mockForConstraintsTests(Department)

        def dep = new Department(organization: o)
        assertFalse dep.validate()
        assertEquals('nullable', dep.errors['title'])

        dep = new Department(title: 'Title', organization: o)
        assertTrue dep.validate()
    }
}
